import request from '@/utils/request'
import {PageResData, ResponseData} from "@/types/common";

interface QueryShippingPlanQueryData {
  PlanId?: number;
  PlanName?: string;
  ShopId?: number;

  STTime?: string;
  EndTime?: string;

  PageSize?: number;
  PageIndex?: number;
}

export interface ShippingPlanVO {
  ShippingPlanId: number | string;
  Name: string;
  OperateTime?: string;
  OperateUserId?: number;
  OperateUserName?: string;
  ShippingPlanDetails: ShippingPlanDetail[];
}

interface ShippingPlanPO {
  ShippingPlanId?: number;
  Name: string;
  ShippingPlanDetails?: ShippingPlanDetail[];
}

export interface ShippingPlanDetail {
  ShippingPlanDetailId: number|string;
  ShippingPlanId: number;
  SrcShippingCompanyId: number|string;
  ShippingCompanyId: number|string;
  ShopId: number|string;
  Name: string;
  StartTime: string | Date;
  EndTime: string | Date;
  Remark: string;
}

//  查询快递规则
export function QueryShippingPlan(data: QueryShippingPlanQueryData): Promise<ResponseData<PageResData<ShippingPlanVO>>> {
  return request({
    url: '/ShippingPlan/QueryShippingPlan',
    method: 'POST',
    data
  })
}

// 新增发货计划
export function AddShippingPlan(data: ShippingPlanPO): Promise<ResponseData> {
  return request({
    url: '/ShippingPlan/AddShippingPlan',
    method: 'POST',
    data
  })
}

// 修改发货计划
export function ModifyShippingPlan(data: ShippingPlanPO): Promise<ResponseData> {
  return request({
    url: '/ShippingPlan/ModifyShippingPlan',
    method: 'POST',
    data
  })
}

// 删除发货计划
export function DeleteShippingPlan(inShippingPlanId): Promise<ResponseData> {
  return request({
    url: '/ShippingPlan/DeleteShippingPlan',
    method: 'POST',
    params: {inShippingPlanId}
  })
}

// 删除发货计划明细
export function DeleteShippingPlanDetail(inShippingPlanDetailId): Promise<ResponseData> {
  return request({
    url: '/ShippingPlan/DeleteShippingPlanDetail',
    method: 'POST',
    params: {inShippingPlanDetailId}
  })
}
